Word cloud for OneTwo.txt
rr # word cloud for OneTwo.txt df1\(doc_id=1:nrow(df1) colnames(df1)[1]<-\text\
#Here we interpret each line in the document as separate document mycorpus <- Corpus(DataframeSource(df1)) #Creating corpus (collection of text data) mycorpus <- tm_map(mycorpus, removePunctuation) mycorpus <- tm_map(mycorpus, function(x) removeWords(x, stopwords(\english\))) tdm <- TermDocumentMatrix(mycorpus) #Creating term-document matrix m <- as.matrix(tdm) #here we merge all rows v <- sort(rowSums(m),decreasing=TRUE) #Sum up the frequencies of each word d <- data.frame(word = names(v),freq=v) #Create one column=names, second=frequences pal <- brewer.pal(8,\Dark2\) pal <- pal[-(1:2)] #Create palette of colors wordcloud(d\)word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=F, rot.per=.15, colors=pal, vfont=c(serif,))
Word cloud for Five.txt
rr # wordcloud for Five.txt df2\(doc_id=1:nrow(df2) colnames(df2)[1]<-\text\
#Here we interpret each line in the document as separate document mycorpus <- Corpus(DataframeSource(df2)) #Creating corpus (collection of text data) mycorpus <- tm_map(mycorpus, removePunctuation) mycorpus <- tm_map(mycorpus, function(x) removeWords(x, stopwords(\english\))) tdm <- TermDocumentMatrix(mycorpus) #Creating term-document matrix m <- as.matrix(tdm) #here we merge all rows v <- sort(rowSums(m),decreasing=TRUE) #Sum up the frequencies of each word d <- data.frame(word = names(v),freq=v) #Create one column=names, second=frequences pal <- brewer.pal(5,\Dark2\) pal <- pal[-(1:2)] #Create palette of colors wordcloud(d\)word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=F, rot.per=.15, colors=pal, vfont=c(serif,))
Phrase nets for Five.Txt and OneTwo.Txt with connector words
Phrase net for Five.txt
Phrase net for OneTwo.txt
Word Trees
# Olive data
olive <- read.csv("olive.csv", sep = ",", header = TRUE)
olive_shared <- SharedData$new(olive)
eic_lin_scatt <- olive_shared %>%
plot_ly(x = ~linoleic, y =~ eicosenoic) #%>%
#add_markers(list(size = 6, color = "orange"))
We found, for unusually low observations of Eicosenoic it takes the values of 1,2,and 3.
bar_chart <- olive_shared %>%
plot_ly( x =~ Region) %>%
add_histogram() %>%
layout(barmode = "overlay")
bar_chart
bscols(widths=c(2, NA),filter_slider("S", "Stearic", olive_shared, ~stearic)
,subplot(eic_lin_scatt, bar_chart)%>%
highlight(on="plotly_select", dynamic=T, persistent = T, opacityDim = I(1))%>%hide_legend())
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
Adding more colors to the selection color palette.
We recommend setting `persistent` to `FALSE` (the default) because persistent selection mode can now be used by holding the shift key (while triggering the `on` event).
Setting the `off` event (i.e., 'plotly_relayout') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.
Setting the `off` event (i.e., 'plotly_relayout') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.
ara_lin_scatt <- olive_shared %>%
plot_ly(x = ~linolenic, y =~ arachidic)
subplot(eic_lin_scatt, ara_lin_scatt) %>%
highlight(on = "plotly_select", dynamic = T, persistent = T, opacityDim = I(1)) %>%
hide_legend()
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
Adding more colors to the selection color palette.
We recommend setting `persistent` to `FALSE` (the default) because persistent selection mode can now be used by holding the shift key (while triggering the `on` event).
Setting the `off` event (i.e., 'plotly_relayout') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.
Setting the `off` event (i.e., 'plotly_relayout') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.
parcord <- ggparcoord(olive, columns = c(4:11))
d <- plotly_data(ggplotly(parcord)) %>% group_by(.ID)
d1 <-SharedData$new(d, ~.ID)
plot1 <- plot_ly(d1, x = ~variable, y =~value) %>%
add_lines(line = list(width = 0.3)) %>%
add_markers(marker = list(size = 0.3),
text = ~.ID, hoverinfo = "text")
plot1
#3D-plot and parcoord
df=read.csv("flea.csv")
cannot open file 'flea.csv': No such file or directoryError in file(file, "rt") : cannot open the connection
library(ggplot2)
library(plotly)
library(tm)
library(wordcloud)
library(RColorBrewer)
library(crosstalk)
library(GGally)
df1<-read.table("OneTwo.txt",header=F, sep='\n') #Read file
df2<-read.table("Five.txt",header=F, sep='\n')
# word cloud for OneTwo.txt
df1$doc_id=1:nrow(df1)
colnames(df1)[1]<-"text"
#Here we interpret each line in the document as separate document
mycorpus <- Corpus(DataframeSource(df1)) #Creating corpus (collection of text data)
mycorpus <- tm_map(mycorpus, removePunctuation)
mycorpus <- tm_map(mycorpus, function(x) removeWords(x, stopwords("english")))
tdm <- TermDocumentMatrix(mycorpus) #Creating term-document matrix
m <- as.matrix(tdm)
#here we merge all rows
v <- sort(rowSums(m),decreasing=TRUE) #Sum up the frequencies of each word
d <- data.frame(word = names(v),freq=v) #Create one column=names, second=frequences
pal <- brewer.pal(8,"Dark2")
pal <- pal[-(1:2)] #Create palette of colors
wordcloud(d$word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=F, rot.per=.15, colors=pal, vfont=c("sans serif","plain"))
# wordcloud for Five.txt
df2$doc_id=1:nrow(df2)
colnames(df2)[1]<-"text"
#Here we interpret each line in the document as separate document
mycorpus <- Corpus(DataframeSource(df2)) #Creating corpus (collection of text data)
mycorpus <- tm_map(mycorpus, removePunctuation)
mycorpus <- tm_map(mycorpus, function(x) removeWords(x, stopwords("english")))
tdm <- TermDocumentMatrix(mycorpus) #Creating term-document matrix
m <- as.matrix(tdm)
#here we merge all rows
v <- sort(rowSums(m),decreasing=TRUE) #Sum up the frequencies of each word
d <- data.frame(word = names(v),freq=v) #Create one column=names, second=frequences
pal <- brewer.pal(5,"Dark2")
pal <- pal[-(1:2)] #Create palette of colors
wordcloud(d$word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=F, rot.per=.15, colors=pal, vfont=c("sans serif","plain"))
# Olive data
olive <- read.csv("olive.csv", sep = ",", header = TRUE)
olive_shared <- SharedData$new(olive)
eic_lin_scatt <- olive_shared %>%
plot_ly(x = ~linoleic, y =~ eicosenoic) #%>%
#add_markers(list(size = 6, color = "orange"))
bar_chart <- olive_shared %>%
plot_ly( x =~ Region) %>%
add_histogram() %>%
layout(barmode = "overlay")
bar_chart
# linking the scatterplot and bar chart
subplot(eic_lin_scatt, bar_chart) %>%
highlight(on = "plotly_select", dynamic = T, persistent = T, opacityDim = I(1)) %>%
hide_legend()
bscols(widths=c(2, NA),filter_slider("S", "Stearic", olive_shared, ~stearic)
,subplot(eic_lin_scatt, bar_chart)%>%
highlight(on="plotly_select", dynamic=T, persistent = T, opacityDim = I(1))%>%hide_legend())
ara_lin_scatt <- olive_shared %>%
plot_ly(x = ~linolenic, y =~ arachidic)
subplot(eic_lin_scatt, ara_lin_scatt) %>%
highlight(on = "plotly_select", dynamic = T, persistent = T, opacityDim = I(1)) %>%
hide_legend()
parcord <- ggparcoord(olive, columns = c(4:11))
d <- plotly_data(ggplotly(parcord)) %>% group_by(.ID)
d1 <-SharedData$new(d, ~.ID, group = "Olive")
plot1 <- plot_ly(d1, x = ~variable, y =~value) %>%
add_lines(line = list(width = 0.3)) %>%
add_markers(marker = list(size = 0.3),
text = ~.ID, hoverinfo = "text")
plot1
#3D-plot and parcoord
df=read.csv("flea.csv")
d2<-SharedData$new(df)
p<-ggparcoord(flea, columns = c(6,7,2))
d<-plotly_data(ggplotly(p))%>%group_by(.ID)
d1<-SharedData$new(d, ~.ID, group="flea")
p1<-plot_ly(d1, x=~variable, y=~value)%>%
add_lines(line=list(width=0.3))%>%
add_markers(marker=list(size=0.3),
text=~.ID, hoverinfo="text")
flea2=flea[, c("tars1", "aede2", "aede3")]
flea2$.ID=1:nrow(flea)
d2<-SharedData$new(flea2, ~.ID, group="flea")
p3<-plot_ly(d2,x=~tars1,y=~aede2,z=~aede3)%>%add_markers()
bscols(p1%>%highlight(on="plotly_select", dynamic=T, persistent = T, opacityDim = I(1))%>%
hide_legend(),
p3%>%highlight(on="plotly_click", dynamic=T, persistent = T)%>%hide_legend())